Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for games that use DDS textures #1929

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

luizzeroxis
Copy link
Contributor

Description

Fix #1907

Some games use the official GM-GPUTextureCompression extension to use GPU compressed textures. One of the formats supported is BCN compression, which uses the DDS format, at least on Windows. This PR aims to allow games using that to be modded.

Caveats

Although you can load it, there's no support for saving these textures in their original format, so it just saves in PNG format and gives a warning to the user. This works, but obviously will have a performance impact. This compression format is lossy anyway.

Notes

There's other formats supported by this extension, and in other operating systems, hopefully this can be addressed in future PRs.

Copy link

github-actions bot commented Sep 27, 2024

Copy link
Member

@colinator27 colinator27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nitpicks, but looks good on the whole. Ideally before merging completely, we should investigate the feasibility of encoding the BCN format (assuming ImageMagick doesn't fully support it?).

{
// Read entire image
reader.Position = startAddress;
return FromDds(reader.ReadBytes((int)(maxEndOfStreamPosition - startAddress)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If possible, we should be finding the length of the image data using the image contents, rather than using maxEndOfStreamPosition, which can result in unnecessary padding when re-saving with modifications.

Copy link
Contributor Author

@luizzeroxis luizzeroxis Sep 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't think about that! Sadly there's no easy way to find the length in this format. I changed it so it can get the size of file but only without the extra bdata2 field, because getting that is even harder.

return new GMImage(ImageFormat.Dds, width, height, data);
}

private void AddMagickToPngSettings(MagickReadSettings settings)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsure if this is going to stick around in the long run, but this can probably be marked static.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally

@sonic3XE
Copy link

sonic3XE commented Sep 28, 2024

There is another file extension that was never mentioned before. (e.g. .ASTC for mobile platforms, .GNF for playstation platforms)

@luizzeroxis
Copy link
Contributor Author

@sonic3XE Could you send a game that uses it, or tell which custom option and OS creates such format, so it can be tested?

@sonic3XE
Copy link

image

It looks like Android has ASTC available.

@sonic3XE
Copy link

sonic3XE commented Sep 28, 2024

@luizzeroxis
game.droid
UTMT may fail at loading that texture when trying to open.
Also, it has a constant header in hex: 13 AB A1 5C

@sonic3XE
Copy link

sonic3XE commented Oct 7, 2024

GPU-compressed textures are referred as #1932 including DDS, ASTC, and GNF.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error opening Home World Run's data.win file.
3 participants